package com.ybwh.springboot1.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ybwh.springboot1.common.RespData;
import com.ybwh.springboot1.model.vo.AreaVo;

import io.swagger.annotations.Api;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author saytime
 * @since 2018-12-06
 */
@Api(value = "area",tags = "地区管理api")
@Controller
@RequestMapping("/area")
public class AreaController {


	@ApiOperation(value = "分页查询商品信息（包括库存中的）1")
	@ResponseBody
	@RequestMapping("/validate")
	public RespData<Object> validate(@Validated @ModelAttribute AreaVo areaVo, BindingResult bindingResult) {
		if (bindingResult.hasErrors()) {
			for(ObjectError error : bindingResult.getAllErrors()) {
				return RespData.failedResp(error.getDefaultMessage());
			}
		}

		return RespData.successResp(null);
	}

}
